Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Added menu page e2e tests (Issue/167) #168

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

lemmyadams
Copy link
Contributor

addresses #167

@lemmyadams lemmyadams changed the title Chore: Added menu page e2e tests (Issue/3468) Chore: Added menu page e2e tests (Issue/167) Oct 12, 2023
@lemmyadams lemmyadams self-assigned this Oct 12, 2023
@cahirodoherty-learningpool
Copy link
Contributor

Currently blocked by issue 3 of adaptlearning/adapt_framework#3472

@oliverfoster
Copy link
Member

Please sort out the data loading.

@cahirodoherty-learningpool
Copy link
Contributor

Please sort out the data loading.

Hi Oliver, I believe I have addressed this in a new PR into this branch: #173

Can you have a look an confirm if those are the changes you think are needed please

@oliverfoster
Copy link
Member

Can this pr be closed if you have another?

@cahirodoherty-learningpool
Copy link
Contributor

Can this pr be closed if you have another?

The other PR is into this one as I wasn't 100% clear on if the changes I was making were what you had intended

…build (#173)

* Wrap menu item tests in a per-language loop and reference the course build

* Removing language looping from tests

* Destructuring some variables

* Making use of 'data' attribute that is already wrapped

* Fixing paste fail

* Removing duplication

* Performing empty value check and testing for non-writing of element in such cases
@cahirodoherty-learningpool
Copy link
Contributor

@oliverfoster Here is the true PR now to get those tests into the plugin. Apologies again about the roundabout way with my PR into this branch, I just wanted to make sure the relevant changes needed were discussed in isolation.
This is good to sign off on now 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Comment on lines +21 to +49
const { _graphic, body, displayTitle, duration, linkText } = this.data.contentObjects[index];

if (_graphic?.src) {
cy.get('img.menu-item__image').should('exist').should('have.attr', 'src', _graphic.src);
} else {
cy.get('img.menu-item__image').should('not.exist');
}

if (displayTitle) {
cy.get('.menu-item__title').should('contain', displayTitle);
} else {
cy.get('.menu-item__title').should('not.exist');
}

cy.get('menu-item__details-inner').should('contain', _graphic.alt);

if (body) {
cy.get('.menu-item__body').should('contain', body);
} else {
cy.get('.menu-item__body').should('not.exist');
}

if (duration) {
cy.get('.menu-item__duration').should('contain', duration);
} else {
cy.get('.menu-item__duration').should('not.exist');
}

cy.get('button.boxmenu-item__button').should('contain', linkText);
Copy link

@eleanor-heath eleanor-heath Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, rather than putting if else conditions to test for different scenarios we should do some negative and positive testing and each scenario should go into its own test definition. For example you might have a test for it('should display information in each tile when all details exist', () => { as the positive test and another test for it('should not display information in each tile when menu item details do not exist', () => { as the negative test. You could also provide some invalid data as a negative test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also provide some invalid data as a negative test.

If I've understood this correctly - we'd need to provide some invalid data to the course to rerender, which we currently can't do.

There is as yet no way of providing the rendered course with alternative test data. The tests are performed against the provided course data only. The results of this test will consequently vary depending on the course data provided. A single run of this test does not explicitly test all potential scenarios, as would normally be expected from test cases.

The reason for this is that providing a test course for all possible scenarios for each plugin could get quite unmanageable. At the moment this is a halfway house, we have meaningful tests that are course agnostic, at a later date we can run them with various course configurations when we have a need / a strategy for doing so. We will need to work out how to provide alternative JSON and how to rerender the course in that eventuality.


I think the title as it is: should display the correct information in each tile is reasonably self descriptive - where correct information is the six properties as configured.

github-actions bot pushed a commit that referenced this pull request Jan 26, 2024
## [6.5.1](v6.5.0...v6.5.1) (2024-01-26)

### Chore

* Added menu page e2e tests (Issue/167) (#168) ([dc44460](dc44460)), closes [#168](#168) [#173](#173)

### Fix

* Test context calls (#175) ([a6c2b5c](a6c2b5c)), closes [#175](#175)
Copy link

🎉 This PR is included in version 6.5.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants